package com.demo.wechat.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;

/**
 * @Author： mzy
 * @Date： 2025/4/22 上午10:14
 * @Describe：
 */
@Component
@ConfigurationProperties(prefix = "wechat.oauth")
@Data
public class WeChatOAuthProperties {
    private String appId;
    private String appSecret;
    private String redirectUri;
    private String scope;

    // 可以添加一些校验逻辑
    @PostConstruct
    public void validate() {
        if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(appSecret)) {
            throw new IllegalStateException("微信OAuth配置不完整，请检查application.yml");
        }
    }
}
